/*
 * suspendPCB.c
 *
 *  Created on: Oct 2, 2013
 *      Author: Joseph DeLong
 */

#include <stdlib.h>
#include "mpx_pcb.h"

/*
 * SUSPEND PCB
 * Written by Joseph DeLong
 * Debugged by Alex Newcomer
 * Calls find_PCB(), places the PCB in the suspended state and reinserts it to the correct queue if necessary
 * Parameters: Process Name
 */
void suspendPCB(char processName[9]) {
	struct MPX_PCB *pcb;
	pcb = findPCB(processName);
	if(pcb == NULL) { //couldn't find PCB
		printf("Couldn't find PCB %s to SUSPEND.\n", processName);
	}
	else { //PCB found!
		if((*pcb).isSuspended == 1) { //PCB already blocked
			printf("PCB %s is already SUSPENDED.\n", processName);
		}
		else {
			(*pcb).isSuspended = 1; //set state to BLOCKED
//			removePCB(pcb); //remove from ready queue
//			insertPCB(pcb); //add to suspended queue
			printf("PCB %s successfully SUSPENDED.\n", processName);
		}
	}
}
